<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;
/**
 * 后台首页控制器
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
class IndexController extends AdminController {

    /**
     * 后台首页
     * @author 麦当苗儿 <zuojiazi@vip.qq.com>
     */
    function index(){
    	$this->meta_title  = '首页';
        $this->display();
    }
	
    function msgApi() {
    	$msgReturn = array('status'=>1,'info'=>'');
    	$msgPlugins = S('DB_PLUGINS_MSG');
    	if (!$msgPlugins) {
    		$msgPlugins = api('PluginsMsg/lists');
    		S('DB_PLUGINS_MSG',$msgPlugins);
    	}
    	$count = 0;
    	foreach ($msgPlugins as $k=>$v) {
    		$num = api('PluginsMsg/'.$v['name']);
    		if ($num>0) {
    			$findstr = array('[num]', '[url]');
    			$replacestr = array($num, U($v['url']));
    			$info .= str_replace($findstr, $replacestr, $v['template']).'<br/>';
    		}
    		$count += $num;
    	}
    	if ($count == 0) $this->ajaxReturn(0);
    	$msgReturn['info'] = rtrim($info,'<br/>');
    	$this->ajaxReturn($msgReturn);
    }
}
